package au.com.evoCoach.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import au.com.evoCoach.domain.League;
import au.com.evoCoach.domain.Team;

@Repository
public class TeamDAO extends BaseDAO {

	public TeamDAO() {
		super(Team.class);
	}
	
	public List<Team> getTeams(League league) {
		String sql = "from Team where league = :league";
		Query query = getSession().createQuery(sql);
		query.setParameter("league", league);
		
       	return query.list();
	}
	
	public Team getTeam(String coachName, String password) {
		String sql = "from Team where coachName = :coachName and password = :password";
		Query query = getSession().createQuery(sql);
		query.setParameter("password", password);
		query.setParameter("coachName", coachName);
		
       	return (Team) query.uniqueResult();
	}
	
}
